// Hydra.Payload.Proxy.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"
#include "proxy.h"

DWORD WINAPI InternalInitialize(__in  LPVOID lpParameter);
DWORD WINAPI InternalUninitialize(__in  LPVOID lpParameter);

// NOTE: Do not initialize CLR within DllMain function directly
void OnAttachProcess()
{
	CreateThread(NULL, 0, InternalInitialize, NULL, 0, NULL);
}

void OnDetachProcess()
{
	auto hThread = CreateThread(NULL, 0, InternalUninitialize, NULL, 0, NULL);
	WaitForSingleObject(hThread, INFINITE);
}


// Export a mockup API for C invoke
EXTERN_C __declspec(dllexport) void Mockup(void)
{
}

#pragma managed

DWORD WINAPI InternalInitialize(__in  LPVOID lpParameter)
{
	Hydra::Payload::Engine::Start();
	return 0;
}
DWORD WINAPI InternalUninitialize(__in  LPVOID lpParameter)
{
	Hydra::Payload::Engine::Stop();
	return 0;
}

// Export a mockup type for .NET invoke
namespace Hydra{namespace Payload{namespace Proxy{
public ref class Mockup
{
};

}}}